﻿using System.Reflection;
using Abp.Modules;
using Abp.AutoMapper;
using STOWaybillMall.Domain.Products.Model;
using static STOWaybillMall.Products.Dto.GetProductListOutput;

namespace STOWaybillMall
{
    [DependsOn(typeof(STOWaybillMallCoreModule),
        typeof(AbpAutoMapperModule))]

    public class STOWaybillMallApplicationModule : AbpModule
    {
        public override void PreInitialize()
        {
            Configuration.Modules.AbpAutoMapper().Configurators.Add(mapper =>
            {
                //Add your custom AutoMapper mappings here...
                mapper.CreateMap<ProductListInfoDto, ProductListInfo>()
               .ForMember(dto => dto.ProductTitle, options => options.MapFrom(x => $"{x.ProductName}{x.SpecPropGroupName}"))
               .ForMember(dto => dto.ProductCategory, options => options.MapFrom(x => $"{x.ProductCategoryID}"))
               //.ForAllMembers(dto => dto.NullSubstitute(""))
               ;
            });
        }
        public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
        }
    }
}
